package www.meng.com.service;


import org.beetl.sql.core.page.PageResult;

import java.util.List;

/**
 * @author : Mr.Yan
 * @program : www.meng.com.service
 * @create : 2020/10/22
 * @description : 基于Beetlsql3.0版本的工具service
 */
public interface BaseService<T> {


    /**
     * @Author : Yan
     * @Create : 2019/12/19
     * @Description :  find this table all date list
     */
    List<T> find_All();

    /**
     * @Author : Yan
     * @Create : 2019/12/19
     * @Description :  find this table all data list size
     */
    long find_All_Size();

    /**
     * @Author : Yan
     * @Create : 2019/12/19
     * @Description :  find this table one data by primary key
     */
    T find_ObjByPK(Object pk);

    /**
     * @Author : Yan
     * @Create : 2019/12/19
     * @Description :  find this table array data by primary key Array
     */
    List<T> find_ListByPKs(List<?> pks);

    /**
     * @Author : Yan
     * @Create : 2019/12/20
     * @Description :   find this table data by where params
     */
    T find_ObjByWhere(T t);

    /**
     * @Author : Yan
     * @Create : 2019/12/19
     * @Description :  find this table data by where params , this params best Map<String,Object> ; but this data list is disorder
     */
    List<T> find_ListByWhere(T t);

    /**
     * @Author : Yan
     * @Create : 2019/12/19
     * @Description :  find this table data by where params size , this params best Map<String,Object>
     */
    long find_ListByWhere_Size(T t);

    /**
     * @Author : Yan
     * @Create : 2019/12/20
     * @Description :  insert data into this table , include if field is null insert , return primary key
     */
    void insert(T t);

    /**
     * @Author : Yan
     * @Create : 2019/12/20
     * @Description :  insert data into this table , include if field is null no insert , return primary key
     */
    void insert_Selective(T t);

    /**
     * @Author : Yan
     * @Create : 2019/12/20
     * @Description :  insert batch data list into this table , return insert success length
     */
    void insert_Batch(List<T> list);

    /**
     * @Author : Yan
     * @Create : 2019/12/20
     * @Description : update data into this table by primary key, include if field is null update , return update size
     */
    int update_ByPK(T t);

    /**
     * @Author : Yan
     * @Create : 2019/12/20
     * @Description :  update data into this table by primary key, include if field is null no update , return update size
     */
    int update_Selective_ByPK(T t);

    /**
     * @Author : Yan
     * @Create : 2019/12/20
     * @Description :  update batch data list into this table , if field is null update , return insert success length
     */
    int[] update_Batch_ByPK(List<T> list);

    /**
     * @Author : Yan
     * @Create : 2019/12/20
     * @Description :  update batch data list into this table , if field is null no update , return insert success length
     */
    int[] update_BatchSelective_ByPK(List<?> list);

    /**
     * @Author : Yan
     * @Create : 2019/12/20
     * @Description :  first this upsert go select by pk if hava update else insert , include if field is null update or insert, return true is insert 、 false is update
     */
    boolean upsert(T t);

    /**
     * @Author : Yan
     * @Create : 2019/12/20
     * @Description :   first this upsert go select by pk if hava update else insert ,if field is null no update or no insert, return true is insert 、 false is update
     */
    boolean upsert_Selective(T t);

    /**
     * @Author : Yan
     * @Create : 2019/12/20
     * @Description : delete this table by primary key , return delete success length
     */
    int delete_ByPK(Object pk);

    /**
     * @Author : Yan
     * @Create : 2019/12/21
     * @Description : delete this table by primary key Array , return delete success length
     */
    int delete_ByPKArray(Object[] PkArray);

    /**
     * @Author : Yan
     * @Create : 2019/12/21
     * @Description : find page of page and pageSize , return totalRow 、totalpage、list
     */
    PageResult<T> find_Page(long page, int pageSize);

    /**
     * @Author : Yan
     * @Create : 2019/12/21
     * @Description : find page of page and pageSize and t , return totalRow 、totalpage、list
     */
    PageResult<T> find_Page(long page, int pageSize, T t);

    /**
     * @Author : Yan
     * @Create : 2019/12/21
     * @Description : find page of page and pageSize and t and orderBy, return totalRow 、totalpage、list
     */
    PageResult<T> find_Page(long page, int pageSize, T t, String orderBy);

}
